package _18_剑指OfferII;

import java.util.ArrayList;
import java.util.List;

public class _079_剑指OfferII所有子集 {

    List<List<Integer>> results = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {

        dfs(nums, 0, new ArrayList<>());
        return results;
    }

    private void dfs(int[] nums, int index, List<Integer> list) {
        results.add(new ArrayList<>(list));
        if (index == nums.length) return;
        for (int i = index; i < nums.length; ++i) {
            list.add(nums[i]);
            dfs(nums, i + 1, list);
            list.remove(list.size() - 1);
        }
    }

}
